/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-16 15:55:11
 * @LastEditTime: 2021-08-16 15:55:23
 * @LastEditors: changqing
 * @Usage: 
 */
function makeIterator(array) {
  let nextIndex = 0
  return {
    next: function() {
      return nextIndex < array.length ? {
        value: array[nextIndex++],
        done: false
      } : {
        done: true
      };
    }
  };
}

const it = makeIterator(['yo', 'ya']);

console.log(it.next().value); // 'yo'
console.log(it.next().value); // 'ya'
console.log(it.next().done);  // true